

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>安装 Ceph 对象网关 &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/css/custom.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../../_static/favicon.ico"/>
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
        <script src="../../../_static/jquery.js"></script>
        <script src="../../../_static/underscore.js"></script>
        <script src="../../../_static/doctools.js"></script>
    
    <script type="text/javascript" src="../../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../../genindex/" />
    <link rel="search" title="Search" href="../../../search/" />
    <link rel="next" title="Cephadm" href="../../../cephadm/" />
    <link rel="prev" title="升级 Ceph" href="../upgrading-ceph/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../../" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../../">安装 Ceph</a> &raquo;</li>
        
          <li><a href="../">安装 (ceph-deploy)</a> &raquo;</li>
        
      <li>安装 Ceph 对象网关</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
          
            <a href="../../../_sources/install/ceph-deploy/install-ceph-gateway.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../../">
          

          
            
            <img src="../../../_static/logo.png" class="logo" alt="Logo"/>
          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../../start/intro/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../cephfs/">Ceph 文件系统</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../../../radosgw/">Ceph 对象网关</a><ul class="current">
<li class="toctree-l2 current"><a class="current reference internal" href="#">基于 Civetweb 手动安装</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id1">安装前的准备工作</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id2">安装 Ceph 对象网关</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id3">创建网关例程</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id4">更改默认端口</a></li>
<li class="toctree-l3"><a class="reference internal" href="#civetweb-ssl">在 Civetweb 上使用 SSL</a></li>
<li class="toctree-l3"><a class="reference internal" href="#civetweb">额外的 Civetweb 配置选项</a></li>
<li class="toctree-l3"><a class="reference internal" href="#apache-civetweb">从 Apache 迁移到 Civetweb</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id5">桶分片的配置</a></li>
<li class="toctree-l3"><a class="reference internal" href="#dns">增加 DNS 通配符</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id6">开启调试选项（如有必要）</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id7">试用网关</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#s3-radosgw">创建用于 S3 访问的 RADOSGW 用户</a></li>
<li class="toctree-l4"><a class="reference internal" href="#swift">创建 Swift 用户</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id8">访问验证</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/frontends/">HTTP 前端</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/placement/">存储池归置与存储类</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/multisite/">多站配置</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/multisite-sync-policy/">多站同步策略配置</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/pools/">存储池的配置</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/config-ref/">配置参考</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/admin/">管理指南</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/s3/">S3 API</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/rgw-cache/">Data caching and CDN</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/swift/">Swift API</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/adminops/">管理操作 API</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/api/">Python 接口</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/nfs/">通过 NFS 导出</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/keystone/">与 OpenStack Keystone 对接</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/barbican/">与 OpenStack Barbican 对接</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/vault/">与 HashiCorp Vault 对接</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/opa/">与 Open Policy Agent 对接</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/multitenancy/">多租户</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/compression/">压缩</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/ldap-auth/">LDAP 认证</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/encryption/">服务器端加密</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/bucketpolicy/">桶策略</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/dynamicresharding/">动态的桶索引重分片</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/mfa/">多因子认证</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/sync-modules/">同步模块</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/notifications/">Bucket Notifications</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/layout/">RADOS 中的数据布局</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/STS/">STS</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/STSLite/">STS Lite</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/keycloak/">Keycloak</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/role/">Role</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/orphans/">Orphan List and Associated Tooliing</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/oidc/">OpenID Connect Provider</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/troubleshooting/">故障排除</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../man/8/radosgw/">radosgw 手册页</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../man/8/radosgw-admin/">radosgw-admin 手册页</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/qat-accel/">使用 QAT 为加密和压缩提速</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../radosgw/s3select/">S3-select</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <div class="section" id="ceph">
<h1>安装 Ceph 对象网关<a class="headerlink" href="#ceph" title="Permalink to this headline">¶</a></h1>
<p>从 <cite>firefly</cite> (v0.80) 起， Ceph 对象网关开始运行在 Civetweb
（嵌入进了 <code class="docutils literal notranslate"><span class="pre">ceph-radosgw</span></code> 守护进程）之上，不再依赖 Apache
和 FastCGI 。基于 Civetweb 的用法简化了 Ceph 对象网关的安装和配置。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>要提供 Ceph 对象网关服务，你得有正常运行的 Ceph
存储集群、且它的网关主机能访问存储集群的公共网。</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>0.80 版时， Ceph 对象网关还不支持 SSL ，你可以配置个支持 SSL 的反向代理，用来把 HTTPS 请求脱壳为 HTTP 、并调度到 Civetweb 。</p>
</div>
<div class="section" id="id1">
<h2>安装前的准备工作<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h2>
<p>参考<a class="reference external" href="../quick-start-preflight">飞前检查</a>，先在 Ceph 对象网关节点上完成安装前的准备工作。特别要注意， Ceph 部署用户的 <code class="docutils literal notranslate"><span class="pre">requiretty</span></code> 需禁用，
SELinux 需设置为 <code class="docutils literal notranslate"><span class="pre">Permissive</span></code> ， Ceph 部署用户执行
<code class="docutils literal notranslate"><span class="pre">sudo</span></code> 要配置为无需密码。对于 Ceph 对象网关，你得开放
Civetweb 在生产环境下要用到的端口。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Civetweb 默认使用 <code class="docutils literal notranslate"><span class="pre">7480</span></code> 端口。</p>
</div>
</div>
<div class="section" id="id2">
<h2>安装 Ceph 对象网关<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h2>
<p>在管理服务器的工作目录下，把 Ceph 对象网关软件包安装到 Ceph
对象网关节点上。例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">install</span> <span class="o">--</span><span class="n">rgw</span> <span class="o">&lt;</span><span class="n">gateway</span><span class="o">-</span><span class="n">node1</span><span class="o">&gt;</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">gateway</span><span class="o">-</span><span class="n">node2</span><span class="o">&gt;</span> <span class="o">...</span><span class="p">]</span>
</pre></div>
</div>
<p>其中， <code class="docutils literal notranslate"><span class="pre">ceph-common</span></code> 软件包是依赖，所以 <code class="docutils literal notranslate"><span class="pre">ceph-deploy</span></code>
也会安装它。 <code class="docutils literal notranslate"><span class="pre">ceph</span></code> 命令行工具包是用于管理的。要想让你的
Ceph 对象网关节点兼具管理节点的功能，可以在管理节点的工作目录下执行下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">admin</span> <span class="o">&lt;</span><span class="n">node</span><span class="o">-</span><span class="n">name</span><span class="o">&gt;</span>
</pre></div>
</div>
</div>
<div class="section" id="id3">
<h2>创建网关例程<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h2>
<p>在管理服务器的工作目录下，为 Ceph 网关节点创建一个例程。例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">rgw</span> <span class="n">create</span> <span class="o">&lt;</span><span class="n">gateway</span><span class="o">-</span><span class="n">node1</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>网关运行后，你就应该能通过 <code class="docutils literal notranslate"><span class="pre">7480</span></code> 端口访问了，比如用下面这个尚未认证的请求：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="n">client</span><span class="o">-</span><span class="n">node</span><span class="p">:</span><span class="mi">7480</span>
</pre></div>
</div>
<p>如果网关例程可以正常工作，你应该能看到类似如下的响应：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;ListAllMyBucketsResult xmlns=&quot;http://s3.amazonaws.com/doc/2006-03-01/&quot;&gt;
    &lt;Owner&gt;
        &lt;ID&gt;anonymous&lt;/ID&gt;
        &lt;DisplayName&gt;&lt;/DisplayName&gt;
    &lt;/Owner&gt;
    &lt;Buckets&gt;
    &lt;/Buckets&gt;
&lt;/ListAllMyBucketsResult&gt;
</pre></div>
</div>
<p>如果当中哪一步遇到问题了，想重来一次，可以用下列命令清除配置：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">purge</span> <span class="o">&lt;</span><span class="n">gateway</span><span class="o">-</span><span class="n">node1</span><span class="o">&gt;</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">gateway</span><span class="o">-</span><span class="n">node2</span><span class="o">&gt;</span><span class="p">]</span>
<span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="n">purgedata</span> <span class="o">&lt;</span><span class="n">gateway</span><span class="o">-</span><span class="n">node1</span><span class="o">&gt;</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">gateway</span><span class="o">-</span><span class="n">node2</span><span class="o">&gt;</span><span class="p">]</span>
</pre></div>
</div>
<p>如果你执行的是 <code class="docutils literal notranslate"><span class="pre">purge</span></code> ，那你得重新安装 Ceph 软件包。</p>
</div>
<div class="section" id="id4">
<h2>更改默认端口<a class="headerlink" href="#id4" title="Permalink to this headline">¶</a></h2>
<p>Civetweb 默认使用 <code class="docutils literal notranslate"><span class="pre">7480</span></code> 端口。要改变默认端口（如改成 <code class="docutils literal notranslate"><span class="pre">80</span></code>
端口），可以在管理服务器的工作目录下修改配置文件，新增名为
<code class="docutils literal notranslate"><span class="pre">[client.rgw.&lt;gateway-node&gt;]</span></code> 的段，其中，要把
<code class="docutils literal notranslate"><span class="pre">&lt;gateway-node&gt;</span></code> 替换为你 Ceph 对象网关节点的短主机名（即
<code class="docutils literal notranslate"><span class="pre">hostname</span> <span class="pre">-s</span></code> ）。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>从 11.0.1 版起， Ceph 对象网关<strong>才支持</strong> SSL 。如何配置请参考<a class="reference internal" href="#civetweb-ssl">在 Civetweb 上使用 SSL</a> 。</p>
</div>
<p>例如，假设你的节点名为 <code class="docutils literal notranslate"><span class="pre">gateway-node1</span></code> ，可以在 <code class="docutils literal notranslate"><span class="pre">[global]</span></code>
段之后加这样一段：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">client</span><span class="o">.</span><span class="n">rgw</span><span class="o">.</span><span class="n">gateway</span><span class="o">-</span><span class="n">node1</span><span class="p">]</span>
<span class="n">rgw_frontends</span> <span class="o">=</span> <span class="s2">&quot;civetweb port=80&quot;</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>切记，在 <code class="docutils literal notranslate"><span class="pre">rgw_frontends</span></code> 键值对里的
<code class="docutils literal notranslate"><span class="pre">port=&lt;port-number&gt;</span></code> 之中不要加空格。
<code class="docutils literal notranslate"><span class="pre">[client.rgw.gateway-node1]</span></code> 标题表明，这部分 Ceph
配置文件是用于配置 Ceph 存储集群客户端的、客户端类型为 Ceph 对象网关（即 <code class="docutils literal notranslate"><span class="pre">rgw</span></code> ）、且例程名字是
<code class="docutils literal notranslate"><span class="pre">gateway-node1</span></code> 。</p>
</div>
<p>把更新过的配置文件推送到 Ceph 对象网关节点（以及其它 Ceph
节点）：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span><span class="o">-</span><span class="n">deploy</span> <span class="o">--</span><span class="n">overwrite</span><span class="o">-</span><span class="n">conf</span> <span class="n">config</span> <span class="n">push</span> <span class="o">&lt;</span><span class="n">gateway</span><span class="o">-</span><span class="n">node</span><span class="o">&gt;</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">other</span><span class="o">-</span><span class="n">nodes</span><span class="o">&gt;</span><span class="p">]</span>
</pre></div>
</div>
<p>要使新的端口配置生效，重启 Ceph 对象网关即可：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">systemctl</span> <span class="n">restart</span> <span class="n">ceph</span><span class="o">-</span><span class="n">radosgw</span><span class="o">.</span><span class="n">service</span>
</pre></div>
</div>
<p>最后，检查下你选用的端口在防火墙上是否开放了（如 <code class="docutils literal notranslate"><span class="pre">80</span></code>
端口），如果没开放，加上这个端口并重载防火墙配置。如果你用的是 <code class="docutils literal notranslate"><span class="pre">firewalld</span></code> 守护进程，可执行：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">firewall</span><span class="o">-</span><span class="n">cmd</span> <span class="o">--</span><span class="nb">list</span><span class="o">-</span><span class="nb">all</span>
<span class="n">sudo</span> <span class="n">firewall</span><span class="o">-</span><span class="n">cmd</span> <span class="o">--</span><span class="n">zone</span><span class="o">=</span><span class="n">public</span> <span class="o">--</span><span class="n">add</span><span class="o">-</span><span class="n">port</span> <span class="mi">80</span><span class="o">/</span><span class="n">tcp</span> <span class="o">--</span><span class="n">permanent</span>
<span class="n">sudo</span> <span class="n">firewall</span><span class="o">-</span><span class="n">cmd</span> <span class="o">--</span><span class="n">reload</span>
</pre></div>
</div>
<p>如果用的是 <code class="docutils literal notranslate"><span class="pre">iptables</span></code> ，可执行：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">iptables</span> <span class="o">--</span><span class="nb">list</span>
<span class="n">sudo</span> <span class="n">iptables</span> <span class="o">-</span><span class="n">I</span> <span class="n">INPUT</span> <span class="mi">1</span> <span class="o">-</span><span class="n">i</span> <span class="o">&lt;</span><span class="n">iface</span><span class="o">&gt;</span> <span class="o">-</span><span class="n">p</span> <span class="n">tcp</span> <span class="o">-</span><span class="n">s</span> <span class="o">&lt;</span><span class="n">ip</span><span class="o">-</span><span class="n">address</span><span class="o">&gt;/&lt;</span><span class="n">netmask</span><span class="o">&gt;</span> <span class="o">--</span><span class="n">dport</span> <span class="mi">80</span> <span class="o">-</span><span class="n">j</span> <span class="n">ACCEPT</span>
</pre></div>
</div>
<p>需把命令中的 <code class="docutils literal notranslate"><span class="pre">&lt;iface&gt;</span></code> 和 <code class="docutils literal notranslate"><span class="pre">&lt;ip-address&gt;/&lt;netmask&gt;</span></code> 替换成你的 Ceph 对象网关节点上的相关值。</p>
<p>配置完 <code class="docutils literal notranslate"><span class="pre">iptables</span></code> 之后，你得保存配置，如此一来你的 Ceph
对象网关节点重启后防火墙配置还依然有效。命令如下：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">apt</span><span class="o">-</span><span class="n">get</span> <span class="n">install</span> <span class="n">iptables</span><span class="o">-</span><span class="n">persistent</span>
</pre></div>
</div>
<p>会出现一个终端对话框。提示你是否把当前 iptables 的 <code class="docutils literal notranslate"><span class="pre">IPv4</span></code>
规则保存为 <code class="docutils literal notranslate"><span class="pre">/etc/iptables/rules.v4</span></code> 、 <code class="docutils literal notranslate"><span class="pre">IPv6</span></code> 规则保存为
<code class="docutils literal notranslate"><span class="pre">/etc/iptables/rules.v6</span></code> 时选 <code class="docutils literal notranslate"><span class="pre">yes</span></code> 。</p>
<p>前面我们配置的 <code class="docutils literal notranslate"><span class="pre">IPv4</span></code> 的 iptables 规则会从
<code class="docutils literal notranslate"><span class="pre">/etc/iptables/rules.v4</span></code> 载入，且重启后仍然有效。</p>
<p>如果在安装 <code class="docutils literal notranslate"><span class="pre">iptables-persistent</span></code> 之后你还新增过 <code class="docutils literal notranslate"><span class="pre">IPv4</span></code>
的 iptables 规则，你还得把它们手动存入规则文件，这时，你得以 <code class="docutils literal notranslate"><span class="pre">root</span></code> 用户执行下面的命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">iptables</span><span class="o">-</span><span class="n">save</span> <span class="o">&gt;</span> <span class="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">iptables</span><span class="o">/</span><span class="n">rules</span><span class="o">.</span><span class="n">v4</span>
</pre></div>
</div>
</div>
<div class="section" id="civetweb-ssl">
<span id="using-ssl-with-civetweb"></span><h2>在 Civetweb 上使用 SSL<a class="headerlink" href="#civetweb-ssl" title="Permalink to this headline">¶</a></h2>
<p>要在 civetweb 上启用 SSL ，首先你需要一个证书、它应该与提供
Ceph 对象网关服务的域名相对应。考虑到灵活性，你也许应该申请有 <cite>subject alternate name</cite> 字段的证书；如果你想使用 S3 风格的子域名（<a class="reference internal" href="#dns">增加 DNS 通配符</a>），你得申请通配型证书（
<cite>wildcard certificate</cite> ）。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>译者注：你可以采用自认证证书。有些客户端 API 会检查可信证书颁发机构，这样的话你只能向可信机构（如
<a class="reference external" href="https://letsencrypt.org">https://letsencrypt.org</a> ）申请 SSL 证书，才能使用那些客户端 API 。</p>
</div>
<p>Civetweb 要求服务器密钥、服务器证书、以及其它 CA 或者中间证书都在同一个文件里，而且它们都必须是 <cite>pem</cite> 格式。这个整合的文件包含了密钥，所以应该把它保护起来，防止未经授权的访问。</p>
<p>要启用 SSL ，在端口号后面加 <code class="docutils literal notranslate"><span class="pre">s</span></code> 。如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">client</span><span class="o">.</span><span class="n">rgw</span><span class="o">.</span><span class="n">gateway</span><span class="o">-</span><span class="n">node1</span><span class="p">]</span>
<span class="n">rgw_frontends</span> <span class="o">=</span> <span class="n">civetweb</span> <span class="n">port</span><span class="o">=</span><span class="mi">443</span><span class="n">s</span> <span class="n">ssl_certificate</span><span class="o">=/</span><span class="n">etc</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">private</span><span class="o">/</span><span class="n">keyandcert</span><span class="o">.</span><span class="n">pem</span>
</pre></div>
</div>
<div class="versionadded">
<p><span class="versionmodified added">New in version Luminous.</span></p>
</div>
<p>此外， civetweb 还能配置为绑定多个端口，在配置时用 <code class="docutils literal notranslate"><span class="pre">+</span></code> 分隔多个端口号即可。如此一来，单个 rgw 例程就能满足需要同时开放
SSL 和非 SSL 连接的场景。例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">client</span><span class="o">.</span><span class="n">rgw</span><span class="o">.</span><span class="n">gateway</span><span class="o">-</span><span class="n">node1</span><span class="p">]</span>
<span class="n">rgw_frontends</span> <span class="o">=</span> <span class="n">civetweb</span> <span class="n">port</span><span class="o">=</span><span class="mi">80</span><span class="o">+</span><span class="mi">443</span><span class="n">s</span> <span class="n">ssl_certificate</span><span class="o">=/</span><span class="n">etc</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">private</span><span class="o">/</span><span class="n">keyandcert</span><span class="o">.</span><span class="n">pem</span>
</pre></div>
</div>
</div>
<div class="section" id="civetweb">
<h2>额外的 Civetweb 配置选项<a class="headerlink" href="#civetweb" title="Permalink to this headline">¶</a></h2>
<p>还有些额外配置选项可用来调整嵌入式的 Civetweb 网页服务器，位于
<code class="docutils literal notranslate"><span class="pre">ceph.conf</span></code> 文件的 <strong>Ceph 对象网关</strong>一节。
支持的选项、包括例子，都在 <a class="reference external" href="../../../radosgw/frontends">HTTP 前端</a>里。</p>
</div>
<div class="section" id="apache-civetweb">
<h2>从 Apache 迁移到 Civetweb<a class="headerlink" href="#apache-civetweb" title="Permalink to this headline">¶</a></h2>
<p>如果你是基于 Apache 和 FastCGI 运行 Ceph 对象网关的， 而且
Ceph 存储版本是 v0.80 或更高，那么你有条件切换到 Civetweb
——它随 <code class="docutils literal notranslate"><span class="pre">ceph-radosgw</span></code> 守护进程启动、默认运行在 7480 端口上，所以不会与 Apache 和 FastCGI 冲突，与其它常见的网页服务端口也没冲突。向 Civetweb 迁移主要包括删除 Apache 软件包、清除 Ceph 配置文件里的 Apache 和 FastCGI 配置、把
<code class="docutils literal notranslate"><span class="pre">rgw_frontends</span></code> 重置为 Civetweb 。</p>
<p>根据前面的用 <code class="docutils literal notranslate"><span class="pre">ceph-deploy</span></code> 安装 Ceph 对象网关里面的描述，当时的配置文件只配置了 <code class="docutils literal notranslate"><span class="pre">rgw_frontends</span></code> （而且假设你更改了默认端口）， <code class="docutils literal notranslate"><span class="pre">ceph-deploy</span></code> 工具为你生成了数据目录和密钥环——且把密钥环放到了 <code class="docutils literal notranslate"><span class="pre">/var/lib/ceph/radosgw/{rgw-intance}</span></code> 。这个守护进程会到默认位置找密钥，除非你在 Ceph 配置文件里另有配置。你已经有密钥和数据目录了，如果不想用默认路径，你必须在
Ceph 配置文件里单独维护这些路径。</p>
<p>如果基于 Apache 部署，典型的 Ceph 对象网关配置文件类似如下：</p>
<p>在 Red Hat Enterprise Linux 上：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">client</span><span class="o">.</span><span class="n">radosgw</span><span class="o">.</span><span class="n">gateway</span><span class="o">-</span><span class="n">node1</span><span class="p">]</span>
<span class="n">host</span> <span class="o">=</span> <span class="p">{</span><span class="n">hostname</span><span class="p">}</span>
<span class="n">keyring</span> <span class="o">=</span> <span class="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">radosgw</span><span class="o">.</span><span class="n">keyring</span>
<span class="n">rgw</span> <span class="n">socket</span> <span class="n">path</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
<span class="n">log</span> <span class="n">file</span> <span class="o">=</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">log</span><span class="o">/</span><span class="n">radosgw</span><span class="o">/</span><span class="n">client</span><span class="o">.</span><span class="n">radosgw</span><span class="o">.</span><span class="n">gateway</span><span class="o">-</span><span class="n">node1</span><span class="o">.</span><span class="n">log</span>
<span class="n">rgw</span> <span class="n">frontends</span> <span class="o">=</span> <span class="n">fastcgi</span> <span class="n">socket</span>\<span class="n">_port</span><span class="o">=</span><span class="mi">9000</span> <span class="n">socket</span>\<span class="n">_host</span><span class="o">=</span><span class="mf">0.0.0.0</span>
<span class="n">rgw</span> <span class="nb">print</span> <span class="k">continue</span> <span class="o">=</span> <span class="n">false</span>
</pre></div>
</div>
<p>在 Ubuntu 上：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">client</span><span class="o">.</span><span class="n">radosgw</span><span class="o">.</span><span class="n">gateway</span><span class="o">-</span><span class="n">node</span><span class="p">]</span>
<span class="n">host</span> <span class="o">=</span> <span class="p">{</span><span class="n">hostname</span><span class="p">}</span>
<span class="n">keyring</span> <span class="o">=</span> <span class="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">radosgw</span><span class="o">.</span><span class="n">keyring</span>
<span class="n">rgw</span> <span class="n">socket</span> <span class="n">path</span> <span class="o">=</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">run</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">radosgw</span><span class="o">.</span><span class="n">gateway</span><span class="o">.</span><span class="n">fastcgi</span><span class="o">.</span><span class="n">sock</span>
<span class="n">log</span> <span class="n">file</span> <span class="o">=</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">log</span><span class="o">/</span><span class="n">radosgw</span><span class="o">/</span><span class="n">client</span><span class="o">.</span><span class="n">radosgw</span><span class="o">.</span><span class="n">gateway</span><span class="o">-</span><span class="n">node1</span><span class="o">.</span><span class="n">log</span>
</pre></div>
</div>
<p>要改成基于 Civetweb 的，删除 Apache 的专有配置即可，如
<code class="docutils literal notranslate"><span class="pre">rgw_socket_path</span></code> 和 <code class="docutils literal notranslate"><span class="pre">rgw_print_continue</span></code> ；然后，把
<code class="docutils literal notranslate"><span class="pre">rgw_frontends</span></code> 配置内容改成 Civetweb 的、而非 Apache
FastCGI 前端，并指定你想用的端口。例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">client</span><span class="o">.</span><span class="n">radosgw</span><span class="o">.</span><span class="n">gateway</span><span class="o">-</span><span class="n">node1</span><span class="p">]</span>
<span class="n">host</span> <span class="o">=</span> <span class="p">{</span><span class="n">hostname</span><span class="p">}</span>
<span class="n">keyring</span> <span class="o">=</span> <span class="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">ceph</span><span class="o">/</span><span class="n">ceph</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">radosgw</span><span class="o">.</span><span class="n">keyring</span>
<span class="n">log</span> <span class="n">file</span> <span class="o">=</span> <span class="o">/</span><span class="n">var</span><span class="o">/</span><span class="n">log</span><span class="o">/</span><span class="n">radosgw</span><span class="o">/</span><span class="n">client</span><span class="o">.</span><span class="n">radosgw</span><span class="o">.</span><span class="n">gateway</span><span class="o">-</span><span class="n">node1</span><span class="o">.</span><span class="n">log</span>
<span class="n">rgw_frontends</span> <span class="o">=</span> <span class="n">civetweb</span> <span class="n">port</span><span class="o">=</span><span class="mi">80</span>
</pre></div>
</div>
<p>最后，重启 Ceph 对象网关进程。在 Red Hat Enterprise Linux
上执行：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">systemctl</span> <span class="n">restart</span> <span class="n">ceph</span><span class="o">-</span><span class="n">radosgw</span><span class="o">.</span><span class="n">service</span>
</pre></div>
</div>
<p>在 Ubuntu 上执行：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">service</span> <span class="n">radosgw</span> <span class="n">restart</span> <span class="nb">id</span><span class="o">=</span><span class="n">rgw</span><span class="o">.&lt;</span><span class="n">short</span><span class="o">-</span><span class="n">hostname</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>如果你选用的端口没有开放，你还得在防火墙上开放它。</p>
</div>
<div class="section" id="id5">
<h2>桶分片的配置<a class="headerlink" href="#id5" title="Permalink to this headline">¶</a></h2>
<p>Ceph 对象网关把桶的索引数据存储在 <code class="docutils literal notranslate"><span class="pre">index_pool</span></code> 里面，它默认是 <code class="docutils literal notranslate"><span class="pre">.rgw.buckets.index</span></code> 。有时候，用户们会用单个桶放置很多（数十到数百万个对象）对象，如果你没用网关管理接口配置配额、限制单个桶允许的最大对象数，这个桶索引的性能就会明显下降。</p>
<p>在 Ceph 0.94 版中，如果你允许桶内有很多对象，可以把桶索引分片，以此来防止性能瓶颈。
<code class="docutils literal notranslate"><span class="pre">rgw_override_bucket_index_max_shards</span></code> 选项允许你设置每个桶所允许的最大对象数，其默认值是 <code class="docutils literal notranslate"><span class="pre">0</span></code> ，也就是说桶索引的分片功能默认是关闭的。</p>
<p>要打开桶索引分片功能，把
<code class="docutils literal notranslate"><span class="pre">rgw_override_bucket_index_max_shards</span></code> 设置为大于 <code class="docutils literal notranslate"><span class="pre">0</span></code>
的值即可。</p>
<p>想简化配置的话，把 <code class="docutils literal notranslate"><span class="pre">rgw_override_bucket_index_max_shards</span></code>
选项写入 Ceph 配置文件的 <code class="docutils literal notranslate"><span class="pre">[global]</span></code> 段下即可，这样它是系统级的配置，你也可以分别给各个例程单独配置。</p>
<p>在 Ceph 配置文件里改完桶的分片配置后，需重启网关进程。在
Red Hat Enteprise Linux 上需执行：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">systemctl</span> <span class="n">restart</span> <span class="n">ceph</span><span class="o">-</span><span class="n">radosgw</span><span class="o">.</span><span class="n">service</span>
</pre></div>
</div>
<p>在 Ubuntu 上需执行：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">service</span> <span class="n">radosgw</span> <span class="n">restart</span> <span class="nb">id</span><span class="o">=</span><span class="n">rgw</span><span class="o">.&lt;</span><span class="n">short</span><span class="o">-</span><span class="n">hostname</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>在联盟化配置中，为实现故障切换，各区域的 <code class="docutils literal notranslate"><span class="pre">index_pool</span></code> 可能配置得不一样，为使一个 zonegroup 内的各个域的配置保持一致，你可以在网关的 zonegroup 配置中设置
<code class="docutils literal notranslate"><span class="pre">rgw_override_bucket_index_max_shards</span></code> 。例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">radosgw</span><span class="o">-</span><span class="n">admin</span> <span class="n">zonegroup</span> <span class="n">get</span> <span class="o">&gt;</span> <span class="n">zonegroup</span><span class="o">.</span><span class="n">json</span>
</pre></div>
</div>
<p>打开 <code class="docutils literal notranslate"><span class="pre">zonegroup.json</span></code> 文件、编辑相关各域的
<code class="docutils literal notranslate"><span class="pre">bucket_index_max_shards</span></code> 选项，保存到 <code class="docutils literal notranslate"><span class="pre">zonegroup.json</span></code>
文件、并重置此 zonegroup ，例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">radosgw</span><span class="o">-</span><span class="n">admin</span> <span class="n">zonegroup</span> <span class="nb">set</span> <span class="o">&lt;</span> <span class="n">zonegroup</span><span class="o">.</span><span class="n">json</span>
</pre></div>
</div>
<p>更新完 zonegroup 后，再更新并提交 period ，例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">radosgw</span><span class="o">-</span><span class="n">admin</span> <span class="n">period</span> <span class="n">update</span> <span class="o">--</span><span class="n">commit</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>把索引存储池（每个域的索引存储池，可能的话）映射到使用 SSD 的 OSD 组成的 CRUSH 规则也有助于提升桶索引性能。</p>
</div>
</div>
<div class="section" id="dns">
<h2>增加 DNS 通配符<a class="headerlink" href="#dns" title="Permalink to this headline">¶</a></h2>
<p>要想在 Ceph 上使用 S3 风格的子域名（如
bucket-name.domain-name.com ），需要在 DNS 服务器上给这个
<code class="docutils literal notranslate"><span class="pre">ceph-radosgw</span></code> 守护进程使用的域名加一条通配符记录。</p>
<p>DNS 的地址也必须写入 Ceph 配置文件，选项为
<code class="docutils literal notranslate"><span class="pre">rgw</span> <span class="pre">dns</span> <span class="pre">name</span> <span class="pre">=</span> <span class="pre">{hostname}</span></code> 。</p>
<p>对 <code class="docutils literal notranslate"><span class="pre">dnsmasq</span></code> 来说，需增加下面的 address 选项，在主机名前加一点（ . ）：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">address</span><span class="o">=/.</span><span class="p">{</span><span class="n">hostname</span><span class="o">-</span><span class="ow">or</span><span class="o">-</span><span class="n">fqdn</span><span class="p">}</span><span class="o">/</span><span class="p">{</span><span class="n">host</span><span class="o">-</span><span class="n">ip</span><span class="o">-</span><span class="n">address</span><span class="p">}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">address</span><span class="o">=/.</span><span class="n">gateway</span><span class="o">-</span><span class="n">node1</span><span class="o">/</span><span class="mf">192.168.122.75</span>
</pre></div>
</div>
<p>对 <code class="docutils literal notranslate"><span class="pre">bind</span></code> 来说，需加一条通配符记录，例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$TTL    604800
@       IN      SOA     gateway-node1. root.gateway-node1. (
                              2         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      gateway-node1.
@       IN      A       192.168.122.113
*       IN      CNAME   @
</pre></div>
</div>
<p>重启 DNS 服务器、然后用一个子域名 ping 网关服务器，以确保 DNS 解析配置无误：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ping</span> <span class="n">mybucket</span><span class="o">.</span><span class="p">{</span><span class="n">hostname</span><span class="p">}</span>
</pre></div>
</div>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ping</span> <span class="n">mybucket</span><span class="o">.</span><span class="n">gateway</span><span class="o">-</span><span class="n">node1</span>
</pre></div>
</div>
</div>
<div class="section" id="id6">
<h2>开启调试选项（如有必要）<a class="headerlink" href="#id6" title="Permalink to this headline">¶</a></h2>
<p>完成上述配置后，如果它们不如所愿，可以在 Ceph 配置文件的
<code class="docutils literal notranslate"><span class="pre">[global]</span></code> 段下加入调试选项，并重启网关，试着排除配置问题。例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="k">global</span><span class="p">]</span>
<span class="c1">#append the following in the global section.</span>
<span class="n">debug</span> <span class="n">ms</span> <span class="o">=</span> <span class="mi">1</span>
<span class="n">debug</span> <span class="n">rgw</span> <span class="o">=</span> <span class="mi">20</span>
</pre></div>
</div>
</div>
<div class="section" id="id7">
<h2>试用网关<a class="headerlink" href="#id7" title="Permalink to this headline">¶</a></h2>
<p>要使用 REST 接口，首先得创建一个适用于 S3 接口的 Ceph 对象网关用户，然后创建用于 Swift 接口的子用户。之后验证创建的用户是否能访问网关。</p>
<div class="section" id="s3-radosgw">
<h3>创建用于 S3 访问的 RADOSGW 用户<a class="headerlink" href="#s3-radosgw" title="Permalink to this headline">¶</a></h3>
<p>需创建 <code class="docutils literal notranslate"><span class="pre">radosgw</span></code> 用户、并授予权限。其它的命令选项可以查看
<code class="docutils literal notranslate"><span class="pre">man</span> <span class="pre">radosgw-admin</span></code> 。</p>
<p>创建用户可以在 <code class="docutils literal notranslate"><span class="pre">gateway</span> <span class="pre">host</span></code> 上执行下面的命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">radosgw</span><span class="o">-</span><span class="n">admin</span> <span class="n">user</span> <span class="n">create</span> <span class="o">--</span><span class="n">uid</span><span class="o">=</span><span class="s2">&quot;testuser&quot;</span> <span class="o">--</span><span class="n">display</span><span class="o">-</span><span class="n">name</span><span class="o">=</span><span class="s2">&quot;First User&quot;</span>
</pre></div>
</div>
<p>此命令的输出类似如下：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
    <span class="s2">&quot;user_id&quot;</span><span class="p">:</span> <span class="s2">&quot;testuser&quot;</span><span class="p">,</span>
    <span class="s2">&quot;display_name&quot;</span><span class="p">:</span> <span class="s2">&quot;First User&quot;</span><span class="p">,</span>
    <span class="s2">&quot;email&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
    <span class="s2">&quot;suspended&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
    <span class="s2">&quot;max_buckets&quot;</span><span class="p">:</span> <span class="mi">1000</span><span class="p">,</span>
    <span class="s2">&quot;auid&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
    <span class="s2">&quot;subusers&quot;</span><span class="p">:</span> <span class="p">[],</span>
    <span class="s2">&quot;keys&quot;</span><span class="p">:</span> <span class="p">[{</span>
        <span class="s2">&quot;user&quot;</span><span class="p">:</span> <span class="s2">&quot;testuser&quot;</span><span class="p">,</span>
        <span class="s2">&quot;access_key&quot;</span><span class="p">:</span> <span class="s2">&quot;I0PJDPCIYZ665MW88W9R&quot;</span><span class="p">,</span>
        <span class="s2">&quot;secret_key&quot;</span><span class="p">:</span> <span class="s2">&quot;dxaXZ8U90SXydYzyS5ivamEP20hkLSUViiaR+ZDA&quot;</span>
    <span class="p">}],</span>
    <span class="s2">&quot;swift_keys&quot;</span><span class="p">:</span> <span class="p">[],</span>
    <span class="s2">&quot;caps&quot;</span><span class="p">:</span> <span class="p">[],</span>
    <span class="s2">&quot;op_mask&quot;</span><span class="p">:</span> <span class="s2">&quot;read, write, delete&quot;</span><span class="p">,</span>
    <span class="s2">&quot;default_placement&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
    <span class="s2">&quot;placement_tags&quot;</span><span class="p">:</span> <span class="p">[],</span>
    <span class="s2">&quot;bucket_quota&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s2">&quot;enabled&quot;</span><span class="p">:</span> <span class="n">false</span><span class="p">,</span>
        <span class="s2">&quot;max_size_kb&quot;</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span>
        <span class="s2">&quot;max_objects&quot;</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span>
    <span class="p">},</span>
    <span class="s2">&quot;user_quota&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s2">&quot;enabled&quot;</span><span class="p">:</span> <span class="n">false</span><span class="p">,</span>
        <span class="s2">&quot;max_size_kb&quot;</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span>
        <span class="s2">&quot;max_objects&quot;</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span>
    <span class="p">},</span>
    <span class="s2">&quot;temp_url_keys&quot;</span><span class="p">:</span> <span class="p">[]</span>
<span class="p">}</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>访问验证需要 <code class="docutils literal notranslate"><span class="pre">keys-&gt;access_key</span></code> 和
<code class="docutils literal notranslate"><span class="pre">keys-&gt;secret_key</span></code> 的值。</p>
</div>
<div class="admonition important">
<p class="admonition-title">Important</p>
<p>仔细检查输出的密钥。有时候 <code class="docutils literal notranslate"><span class="pre">radosgw-admin</span></code>
生成的 JSON 里的 <code class="docutils literal notranslate"><span class="pre">access_key</span></code> 或 <code class="docutils literal notranslate"><span class="pre">secret_key</span></code> 里面有转义字符 <code class="docutils literal notranslate"><span class="pre">\</span></code> ，而有些客户端不能处理 JSON 转义字符。补救方法可以是删除 JSON 转义字符 <code class="docutils literal notranslate"><span class="pre">\</span></code> 、并用引号把它们包起来；重新生成不含 JSON 转义字符的 key ；或者手动指定 key
和密钥。或者，如果 <code class="docutils literal notranslate"><span class="pre">radosgw-admin</span></code> 生成的 JSON 同时包含转义字符 <code class="docutils literal notranslate"><span class="pre">\</span></code> 和正斜线 <code class="docutils literal notranslate"><span class="pre">/</span></code> ，如 <code class="docutils literal notranslate"><span class="pre">\/</span></code> ，只需删除
JSON 转义字符即可，不要删除正斜线 <code class="docutils literal notranslate"><span class="pre">/</span></code> ，因为它是 key
的合法字符。</p>
</div>
</div>
<div class="section" id="swift">
<h3>创建 Swift 用户<a class="headerlink" href="#swift" title="Permalink to this headline">¶</a></h3>
<p>如果要通过 Swift 接口访问，需创建 Swift 子用户。 Swift 用户的创建包含两步，第一步是创建用户，第二步是创建密钥。</p>
<p>在 <code class="docutils literal notranslate"><span class="pre">gateway</span> <span class="pre">host</span></code> 上执行以下各步骤：</p>
<p>创建 Swift 用户：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">radosgw</span><span class="o">-</span><span class="n">admin</span> <span class="n">subuser</span> <span class="n">create</span> <span class="o">--</span><span class="n">uid</span><span class="o">=</span><span class="n">testuser</span> <span class="o">--</span><span class="n">subuser</span><span class="o">=</span><span class="n">testuser</span><span class="p">:</span><span class="n">swift</span> <span class="o">--</span><span class="n">access</span><span class="o">=</span><span class="n">full</span>
</pre></div>
</div>
<p>其输出类似如下：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
    <span class="s2">&quot;user_id&quot;</span><span class="p">:</span> <span class="s2">&quot;testuser&quot;</span><span class="p">,</span>
    <span class="s2">&quot;display_name&quot;</span><span class="p">:</span> <span class="s2">&quot;First User&quot;</span><span class="p">,</span>
    <span class="s2">&quot;email&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
    <span class="s2">&quot;suspended&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
    <span class="s2">&quot;max_buckets&quot;</span><span class="p">:</span> <span class="mi">1000</span><span class="p">,</span>
    <span class="s2">&quot;auid&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
    <span class="s2">&quot;subusers&quot;</span><span class="p">:</span> <span class="p">[{</span>
        <span class="s2">&quot;id&quot;</span><span class="p">:</span> <span class="s2">&quot;testuser:swift&quot;</span><span class="p">,</span>
        <span class="s2">&quot;permissions&quot;</span><span class="p">:</span> <span class="s2">&quot;full-control&quot;</span>
    <span class="p">}],</span>
    <span class="s2">&quot;keys&quot;</span><span class="p">:</span> <span class="p">[{</span>
        <span class="s2">&quot;user&quot;</span><span class="p">:</span> <span class="s2">&quot;testuser:swift&quot;</span><span class="p">,</span>
        <span class="s2">&quot;access_key&quot;</span><span class="p">:</span> <span class="s2">&quot;3Y1LNW4Q6X0Y53A52DET&quot;</span><span class="p">,</span>
        <span class="s2">&quot;secret_key&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span>
    <span class="p">},</span> <span class="p">{</span>
        <span class="s2">&quot;user&quot;</span><span class="p">:</span> <span class="s2">&quot;testuser&quot;</span><span class="p">,</span>
        <span class="s2">&quot;access_key&quot;</span><span class="p">:</span> <span class="s2">&quot;I0PJDPCIYZ665MW88W9R&quot;</span><span class="p">,</span>
        <span class="s2">&quot;secret_key&quot;</span><span class="p">:</span> <span class="s2">&quot;dxaXZ8U90SXydYzyS5ivamEP20hkLSUViiaR+ZDA&quot;</span>
    <span class="p">}],</span>
    <span class="s2">&quot;swift_keys&quot;</span><span class="p">:</span> <span class="p">[],</span>
    <span class="s2">&quot;caps&quot;</span><span class="p">:</span> <span class="p">[],</span>
    <span class="s2">&quot;op_mask&quot;</span><span class="p">:</span> <span class="s2">&quot;read, write, delete&quot;</span><span class="p">,</span>
    <span class="s2">&quot;default_placement&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
    <span class="s2">&quot;placement_tags&quot;</span><span class="p">:</span> <span class="p">[],</span>
    <span class="s2">&quot;bucket_quota&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s2">&quot;enabled&quot;</span><span class="p">:</span> <span class="n">false</span><span class="p">,</span>
        <span class="s2">&quot;max_size_kb&quot;</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span>
        <span class="s2">&quot;max_objects&quot;</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span>
    <span class="p">},</span>
    <span class="s2">&quot;user_quota&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s2">&quot;enabled&quot;</span><span class="p">:</span> <span class="n">false</span><span class="p">,</span>
        <span class="s2">&quot;max_size_kb&quot;</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span>
        <span class="s2">&quot;max_objects&quot;</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span>
    <span class="p">},</span>
    <span class="s2">&quot;temp_url_keys&quot;</span><span class="p">:</span> <span class="p">[]</span>
<span class="p">}</span>
</pre></div>
</div>
<p>创建密钥：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">radosgw</span><span class="o">-</span><span class="n">admin</span> <span class="n">key</span> <span class="n">create</span> <span class="o">--</span><span class="n">subuser</span><span class="o">=</span><span class="n">testuser</span><span class="p">:</span><span class="n">swift</span> <span class="o">--</span><span class="n">key</span><span class="o">-</span><span class="nb">type</span><span class="o">=</span><span class="n">swift</span> <span class="o">--</span><span class="n">gen</span><span class="o">-</span><span class="n">secret</span>
</pre></div>
</div>
<p>其输出类似如下：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
    <span class="s2">&quot;user_id&quot;</span><span class="p">:</span> <span class="s2">&quot;testuser&quot;</span><span class="p">,</span>
    <span class="s2">&quot;display_name&quot;</span><span class="p">:</span> <span class="s2">&quot;First User&quot;</span><span class="p">,</span>
    <span class="s2">&quot;email&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
    <span class="s2">&quot;suspended&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
    <span class="s2">&quot;max_buckets&quot;</span><span class="p">:</span> <span class="mi">1000</span><span class="p">,</span>
    <span class="s2">&quot;auid&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
    <span class="s2">&quot;subusers&quot;</span><span class="p">:</span> <span class="p">[{</span>
        <span class="s2">&quot;id&quot;</span><span class="p">:</span> <span class="s2">&quot;testuser:swift&quot;</span><span class="p">,</span>
        <span class="s2">&quot;permissions&quot;</span><span class="p">:</span> <span class="s2">&quot;full-control&quot;</span>
    <span class="p">}],</span>
    <span class="s2">&quot;keys&quot;</span><span class="p">:</span> <span class="p">[{</span>
        <span class="s2">&quot;user&quot;</span><span class="p">:</span> <span class="s2">&quot;testuser:swift&quot;</span><span class="p">,</span>
        <span class="s2">&quot;access_key&quot;</span><span class="p">:</span> <span class="s2">&quot;3Y1LNW4Q6X0Y53A52DET&quot;</span><span class="p">,</span>
        <span class="s2">&quot;secret_key&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span>
    <span class="p">},</span> <span class="p">{</span>
        <span class="s2">&quot;user&quot;</span><span class="p">:</span> <span class="s2">&quot;testuser&quot;</span><span class="p">,</span>
        <span class="s2">&quot;access_key&quot;</span><span class="p">:</span> <span class="s2">&quot;I0PJDPCIYZ665MW88W9R&quot;</span><span class="p">,</span>
        <span class="s2">&quot;secret_key&quot;</span><span class="p">:</span> <span class="s2">&quot;dxaXZ8U90SXydYzyS5ivamEP20hkLSUViiaR+ZDA&quot;</span>
    <span class="p">}],</span>
    <span class="s2">&quot;swift_keys&quot;</span><span class="p">:</span> <span class="p">[{</span>
        <span class="s2">&quot;user&quot;</span><span class="p">:</span> <span class="s2">&quot;testuser:swift&quot;</span><span class="p">,</span>
        <span class="s2">&quot;secret_key&quot;</span><span class="p">:</span> <span class="s2">&quot;244+fz2gSqoHwR3lYtSbIyomyPHf3i7rgSJrF\/IA&quot;</span>
    <span class="p">}],</span>
    <span class="s2">&quot;caps&quot;</span><span class="p">:</span> <span class="p">[],</span>
    <span class="s2">&quot;op_mask&quot;</span><span class="p">:</span> <span class="s2">&quot;read, write, delete&quot;</span><span class="p">,</span>
    <span class="s2">&quot;default_placement&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
    <span class="s2">&quot;placement_tags&quot;</span><span class="p">:</span> <span class="p">[],</span>
    <span class="s2">&quot;bucket_quota&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s2">&quot;enabled&quot;</span><span class="p">:</span> <span class="n">false</span><span class="p">,</span>
        <span class="s2">&quot;max_size_kb&quot;</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span>
        <span class="s2">&quot;max_objects&quot;</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span>
    <span class="p">},</span>
    <span class="s2">&quot;user_quota&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s2">&quot;enabled&quot;</span><span class="p">:</span> <span class="n">false</span><span class="p">,</span>
        <span class="s2">&quot;max_size_kb&quot;</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span>
        <span class="s2">&quot;max_objects&quot;</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span>
    <span class="p">},</span>
    <span class="s2">&quot;temp_url_keys&quot;</span><span class="p">:</span> <span class="p">[]</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="id8">
<h3>访问验证<a class="headerlink" href="#id8" title="Permalink to this headline">¶</a></h3>
<div class="section" id="s3">
<h4>测试 S3 访问<a class="headerlink" href="#s3" title="Permalink to this headline">¶</a></h4>
<p>你得写个 Python 测试脚本并运行它来验证 S3 访问。这个 S3 访问测试脚本会连接到 <code class="docutils literal notranslate"><span class="pre">radosgw</span></code> 、创建新桶、并罗列所有桶。其中，
<code class="docutils literal notranslate"><span class="pre">aws_access_key_id</span></code> 和 <code class="docutils literal notranslate"><span class="pre">aws_secret_access_key</span></code> 的值取自
<code class="docutils literal notranslate"><span class="pre">radosgw-admin</span></code> 命令返回的 <code class="docutils literal notranslate"><span class="pre">access_key</span></code> 和 <code class="docutils literal notranslate"><span class="pre">secret_key</span></code> 的值。</p>
<p>执行下列步骤：</p>
<ol class="arabic">
<li><p>先要安装 <code class="docutils literal notranslate"><span class="pre">python-boto</span></code> 软件包：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">yum</span> <span class="n">install</span> <span class="n">python</span><span class="o">-</span><span class="n">boto</span>
</pre></div>
</div>
</li>
<li><p>创建 Python 脚本：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">vi</span> <span class="n">s3test</span><span class="o">.</span><span class="n">py</span>
</pre></div>
</div>
</li>
<li><p>把下面的内容写入这个脚本文件：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">boto.s3.connection</span>

<span class="n">access_key</span> <span class="o">=</span> <span class="s1">&#39;I0PJDPCIYZ665MW88W9R&#39;</span>
<span class="n">secret_key</span> <span class="o">=</span> <span class="s1">&#39;dxaXZ8U90SXydYzyS5ivamEP20hkLSUViiaR+ZDA&#39;</span>
<span class="n">conn</span> <span class="o">=</span> <span class="n">boto</span><span class="o">.</span><span class="n">connect_s3</span><span class="p">(</span>
        <span class="n">aws_access_key_id</span><span class="o">=</span><span class="n">access_key</span><span class="p">,</span>
        <span class="n">aws_secret_access_key</span><span class="o">=</span><span class="n">secret_key</span><span class="p">,</span>
        <span class="n">host</span><span class="o">=</span><span class="s1">&#39;</span><span class="si">{hostname}</span><span class="s1">&#39;</span><span class="p">,</span> <span class="n">port</span><span class="o">=</span><span class="p">{</span><span class="n">port</span><span class="p">},</span>
        <span class="n">is_secure</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">calling_format</span><span class="o">=</span><span class="n">boto</span><span class="o">.</span><span class="n">s3</span><span class="o">.</span><span class="n">connection</span><span class="o">.</span><span class="n">OrdinaryCallingFormat</span><span class="p">(),</span>
       <span class="p">)</span>

<span class="n">bucket</span> <span class="o">=</span> <span class="n">conn</span><span class="o">.</span><span class="n">create_bucket</span><span class="p">(</span><span class="s1">&#39;my-new-bucket&#39;</span><span class="p">)</span>
<span class="k">for</span> <span class="n">bucket</span> <span class="ow">in</span> <span class="n">conn</span><span class="o">.</span><span class="n">get_all_buckets</span><span class="p">():</span>
    <span class="nb">print</span> <span class="s2">&quot;</span><span class="si">{name}</span><span class="s2"> </span><span class="si">{created}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
        <span class="n">name</span><span class="o">=</span><span class="n">bucket</span><span class="o">.</span><span class="n">name</span><span class="p">,</span>
        <span class="n">created</span><span class="o">=</span><span class="n">bucket</span><span class="o">.</span><span class="n">creation_date</span><span class="p">,</span>
    <span class="p">)</span>
</pre></div>
</div>
<p>把上面的 <code class="docutils literal notranslate"><span class="pre">{hostname}</span></code> 替换成你配置了网关服务（即
<code class="docutils literal notranslate"><span class="pre">gateway</span> <span class="pre">host</span></code> ）的主机名，把 <code class="docutils literal notranslate"><span class="pre">{port}</span></code> 替换为你配置的 Civetweb 端口号。</p>
</li>
<li><p>运行此脚本：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="n">s3test</span><span class="o">.</span><span class="n">py</span>
</pre></div>
</div>
<p>其输出应该类似如下：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">my</span><span class="o">-</span><span class="n">new</span><span class="o">-</span><span class="n">bucket</span> <span class="mi">2015</span><span class="o">-</span><span class="mi">02</span><span class="o">-</span><span class="mi">16</span><span class="n">T17</span><span class="p">:</span><span class="mi">09</span><span class="p">:</span><span class="mf">10.000</span><span class="n">Z</span>
</pre></div>
</div>
</li>
</ol>
</div>
<div class="section" id="id9">
<h4>测试 Swift 访问<a class="headerlink" href="#id9" title="Permalink to this headline">¶</a></h4>
<p>Swift 访问可用 <code class="docutils literal notranslate"><span class="pre">swift</span></code> 命令行客户端验证，其命令行选项可用
<code class="docutils literal notranslate"><span class="pre">man</span> <span class="pre">swift</span></code> 获取。</p>
<p><code class="docutils literal notranslate"><span class="pre">swift</span></code> 客户端的安装可用下列命令。在 Red Hat Enteprise
Linux 上：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">yum</span> <span class="n">install</span> <span class="n">python</span><span class="o">-</span><span class="n">setuptools</span>
<span class="n">sudo</span> <span class="n">easy_install</span> <span class="n">pip</span>
<span class="n">sudo</span> <span class="n">pip</span> <span class="n">install</span> <span class="o">--</span><span class="n">upgrade</span> <span class="n">setuptools</span>
<span class="n">sudo</span> <span class="n">pip</span> <span class="n">install</span> <span class="o">--</span><span class="n">upgrade</span> <span class="n">python</span><span class="o">-</span><span class="n">swiftclient</span>
</pre></div>
</div>
<p>在基于 Debian 的发行版上：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">sudo</span> <span class="n">apt</span><span class="o">-</span><span class="n">get</span> <span class="n">install</span> <span class="n">python</span><span class="o">-</span><span class="n">setuptools</span>
<span class="n">sudo</span> <span class="n">easy_install</span> <span class="n">pip</span>
<span class="n">sudo</span> <span class="n">pip</span> <span class="n">install</span> <span class="o">--</span><span class="n">upgrade</span> <span class="n">setuptools</span>
<span class="n">sudo</span> <span class="n">pip</span> <span class="n">install</span> <span class="o">--</span><span class="n">upgrade</span> <span class="n">python</span><span class="o">-</span><span class="n">swiftclient</span>
</pre></div>
</div>
<p>swift 访问可用下列命令验证：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">swift</span> <span class="o">-</span><span class="n">V</span> <span class="mi">1</span> <span class="o">-</span><span class="n">A</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="p">{</span><span class="n">IP</span> <span class="n">ADDRESS</span><span class="p">}:{</span><span class="n">port</span><span class="p">}</span><span class="o">/</span><span class="n">auth</span> <span class="o">-</span><span class="n">U</span> <span class="n">testuser</span><span class="p">:</span><span class="n">swift</span> <span class="o">-</span><span class="n">K</span> <span class="s1">&#39;</span><span class="si">{swift_secret_key}</span><span class="s1">&#39;</span> <span class="nb">list</span>
</pre></div>
</div>
<p>把 <code class="docutils literal notranslate"><span class="pre">{IP</span> <span class="pre">ADDRESS}</span></code> 替换成网关服务器的公网 IP 地址；
<code class="docutils literal notranslate"><span class="pre">{swift_secret_key}</span></code> 替换为创建 <code class="docutils literal notranslate"><span class="pre">swift</span></code> 用户（从
<code class="docutils literal notranslate"><span class="pre">radosgw-admin</span> <span class="pre">key</span> <span class="pre">create</span></code> 命令的输出里提取）时取得的密钥； <code class="docutils literal notranslate"><span class="pre">{port}</span></code> 替换为你配置的 Civetweb 端口号（如默认的
<code class="docutils literal notranslate"><span class="pre">7480</span></code> ），如果你不替换，它将默认为 <code class="docutils literal notranslate"><span class="pre">80</span></code> 端口。</p>
<p>例如：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">swift</span> <span class="o">-</span><span class="n">V</span> <span class="mi">1</span> <span class="o">-</span><span class="n">A</span> <span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="mf">10.19.143.116</span><span class="p">:</span><span class="mi">7480</span><span class="o">/</span><span class="n">auth</span> <span class="o">-</span><span class="n">U</span> <span class="n">testuser</span><span class="p">:</span><span class="n">swift</span> <span class="o">-</span><span class="n">K</span> <span class="s1">&#39;244+fz2gSqoHwR3lYtSbIyomyPHf3i7rgSJrF/IA&#39;</span> <span class="nb">list</span>
</pre></div>
</div>
<p>其输出应该是：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">my</span><span class="o">-</span><span class="n">new</span><span class="o">-</span><span class="n">bucket</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>



           </div>
           
          </div>
          <footer>
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
        <a href="../../../cephadm/" class="btn btn-neutral float-right" title="Cephadm" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
        <a href="../upgrading-ceph/" class="btn btn-neutral float-left" title="升级 Ceph" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).

    </p>
  </div> 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>